import javax.swing.*;
import java.awt.*;

public class fileOpenCommand extends JMenuItem implements Command {
    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JFileChooser fileChooser;
    private JPanel panel;
   
    public fileOpenCommand(JPanel panel)
    {
        this.panel=panel;
        this.fileChooser=new JFileChooser();
    }
    public void execute()
    {
        panel.setBackground(Color.WHITE);
        
        try{
            String selectedFile=fileChooser.getSelectedFile().toString();
            if(selectedFile!=null)//afisarea fiiserului selectat (daca exista), altfel se va trata cazul de eroare
	            {
	                JOptionPane.showMessageDialog(panel,"Ati selectat fisierul urmator: "+selectedFile, "Mesaj", JOptionPane.YES_OPTION );
	            }
        	}
          catch(NullPointerException e)
          	{
               JOptionPane.showMessageDialog(panel,"Nu ati selectat niciun fisier","Mesaj", JOptionPane.YES_OPTION);
            }

        
        
        
        
    } 

}
